package com.wash.car.web.controller.admin;

import com.github.pagehelper.PageInfo;
import com.pmo.boot.common.api.BaseResult;
import com.pmo.boot.common.api.DefaultResult;
import com.wash.car.biz.VipServer;
import com.wash.car.dao.model.VipAddModel;
import com.wash.car.dao.model.VipPageModel;
import com.wash.car.dao.model.VipPageWhereModel;
import com.wash.car.web.config.context.UserContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = {"VIP管理"})
@RestController
@RequestMapping(path = "/admin/vip")
public class AdminVipController {

    @Autowired
    private VipServer vipServer;


    @ApiOperation(value = "添加车牌")
    @PostMapping(path = "add")
    public BaseResult add(@RequestBody VipAddModel model) {
        vipServer.add(model.setUserId(UserContext.get().getUserId()));
        return BaseResult.success();
    }


    @ApiOperation(value = "车牌管理")
    @GetMapping(path = "page")
    public DefaultResult<PageInfo<VipPageModel>> page(VipPageWhereModel model) {
        PageInfo<VipPageModel> pageInfo = vipServer.page(model);
        return DefaultResult.success(pageInfo);
    }

}
